<?php 
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
 * file: test3/mvc/protected/views/index/index.php
 */
?>
<script type="text/javascript">
    $(document).ready(function() {
        $("#submit").css({'background-color':'lightblue','padding-left':'30px','border':'1px solid lightgrey','width':'100px'});        
        $("#submit").mouseover(function(){$(this).css({'cursor':'pointer','background-color':'blue'});});
        $("#submit").mouseout(function(){$(this).css({'background-color':'lightblue'});});
        $("#submit").click(function(ev){
            
            var r2s = new application.server.request2server();
            
            r2s.entryPoint.name = 'index.php';
            r2s.controller.name = 'index';
            r2s.controller.action.name = 'echo2client';
            //r2s.controller.action.param = $("#text2send").val();
            r2s.controller.action.param = '';
            r2s.data = '';
            
            var ajax_request = application.server.request(r2s);
            
            ajax_request.done(function(data){
                $("#results_encrypted").val(JSON.stringify(data));
            });
            
            ajax_request.fail(function(jqXHR, textStatus){
                $("#results_encrypted").val('Request failed: '+textStatus);
            });
            
            return false;
        });
        
        
    });


</script>

<h1>Index</h1>

<p>This is the main page welcome!</p>


<p><textarea id="text2send"rows="4" cols="50" placeholder="Enter the text to be encrypted..." autofocus="autofocus"></textarea></p>
<div id="submit">Send</div>

<hr />

<p>Text encrypted by the server</p>
<p><textarea id="results_encrypted" rows="4" cols="50" ></textarea></p>

<br />
<p>Text decrypted by the server</p>
<p><textarea id="results_decrypted" rows="4" cols="50" readonly="readonly"></textarea></p>

